home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-23 | 3.2 KB | 106 lines | [TEXT/CWIE] |
- //---------------------------------------------------------------------------------------
- //
- // ComboBoxListMouseDown.c -- Source for ComboBox external list window mouse handler
- //
- // Copyright ©1995-1996, Pensacola Christian College
- //
- // ======================================================================
- // Change History
- // ======================================================================
- //
- // 1.0 08/ /95 Steve Dwire
- // Initial release
- //
- // 1.1 a1 10/26/95 Steve Dwire
- // Make closing the List call the script
- //
- // 1.1 11/17/95 Steve Dwire
- // Because kCallTheScript can be passed only from a user event in
- // the main process, I can't call the script directly when the user
- // clicks in the list window to close it. So I'm making
- // ListMouseDown() post a unique keystroke (command-@, without shift)
- // as an autoKey event. When I get that autokeystroke, I will pass
- // back kCallTheScript. By making this an autoKey instead of a
- // keyDown event, I allow a command-@ keystroke to be passed for
- // those who have keyboards that will actually let them type one
- // without using the shift key.
- //
- //---------------------------------------------------------------------------------------
-
- #include <Ext4D.h>
- #include <QuickDraw.h>
- #include "ComboBoxListMouseDown.h" // Include your header here.
-
-
- //---------------------------------------------------------------------------------
- //
- // FUNCTION: ListMouseDown
- //
- //---------------------------------------------------------------------------------
-
- void ListMouseDown(AreaHnd AreaDataHnd, EventRecord* event, WindowPtr ListWindow)
- {
- short offset,len,oldItem;
- Cell theCell;
- ListHandle ListHnd;
- TEHandle TextTEHnd;
- Ptr CellTextPtr;
- GrafPtr savePort;
- Point mousePt;
-
- theCell.h = 0;
- theCell.v = 0;
- ListHnd = (*AreaDataHnd)->ListHnd;
- if(LGetSelect(true,&theCell,ListHnd))
- {
- oldItem = theCell.v+1;
- theCell.h = 0;
- theCell.v = 0;
- }
- else
- oldItem = 0;
-
- if(ListHnd)
- {
- GetPort(&savePort);
- SetPort(ListWindow);
- mousePt = event->where;
- GlobalToLocal(&mousePt);
- LClick(mousePt, 0, ListHnd);
- if(event->where.h < (*AreaDataHnd)->ListRect.right-kScrollBarWidth)
- {
- TextTEHnd = (*AreaDataHnd)->TextTEHnd;
- if(TextTEHnd)
- {
- if(LGetSelect(true,&theCell,ListHnd))
- {
- LGetCellDataLocation(&offset,&len,theCell,ListHnd);
- CellTextPtr = NewPtr(len+1);
- if(!MemError())
- {
- if (theCell.v+1 != oldItem)
- (*AreaDataHnd)->Flags.Modified = true;
- TEDeactivate(TextTEHnd);
- LGetCell(CellTextPtr,&len,theCell,ListHnd);
- TESetText(CellTextPtr, (long) len, TextTEHnd);
- DisposePtr(CellTextPtr);
- TESetSelect(0,32767,TextTEHnd);
- TEActivate(TextTEHnd);
- SetPort((*AreaDataHnd)->AreaGrafPort);
- InvalRect(&(*AreaDataHnd)->AreaRect);
- }
- (*AreaDataHnd)->Flags.Open = false;
- HideWindow(ListWindow);
- //v1.1
- // changed the following line from v1.1 a1:
- //event->message = kCallTheScript;
- // into the following line:
- PostKey((unsigned long)'@',(unsigned long)cmdKey,true);
- // so that closing the list will _really_ call the script.
- }
- }
- }
- SetPort(savePort);
- }
- }
-